import { AxiosResponse } from 'axios';
export interface CommonRes<R> {
  success: boolean;
  data: R;
}

export enum HttpMethodsTD {
  GET = 'get',
  POST = 'post',
  PUT = 'put',
  DELETE = 'delete',
}

export interface HttpConfigTD<R> {
  name: string;
  method: HttpMethodsTD;
  url: string;
  headers?: { [key: string]: string };
  transformResponse?: (res: AxiosResponse<CommonRes<R>>) => any;
}

export class HttpConfig implements HttpConfigTD<any> {
  public name: string;
  public method: HttpMethodsTD;
  public url: string;
  public headers?: { [key: string]: string };
  public transformResponse?: (res: AxiosResponse<CommonRes<any>>) => any;
  constructor(config: HttpConfigTD<any>) {
    this.name = config.name;
    this.method = config.method;
    this.url = config.url;
    this.headers = config.headers;
    this.transformResponse = config.transformResponse;
  }

  get status() {
    return this.name + 'Status';
  }
}
